package com.suyin.ximoon.plugin.mybatis;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * and 或者or  只支持 一层连接，不支持递归连接。不会像Hibernate中的Criteria 那么强大。
 * @author guo
 *
 */
public  class Junction implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6704704403070670627L;
	
	private  List<WhereCondition> whereConditions= new ArrayList<WhereCondition>();
	
	private   String op;
	
	public String getOp() {
		return op;
	}
	public void setOp(String op) {
		this.op = op;
	}

	private List<WhereCondition> opWhereConditions = new ArrayList<WhereCondition>();
	
	public Junction(WhereCondition whereParam,String op,WhereCondition... opWhereConditions) {
		this.opWhereConditions.addAll(Arrays.asList(opWhereConditions));
		this.whereConditions.add(whereParam);
		this.op = op;
	}
	public Junction(List<WhereCondition> whereParams,String op,WhereCondition... opWhereConditions) {
		this.whereConditions.addAll(whereParams);
		this.opWhereConditions.addAll(Arrays.asList(opWhereConditions));
		this.op = op;
	}
	


	public Junction add(WhereCondition whereParam) {
		whereConditions.add(whereParam);
		return this;
	}
	public Junction addOpWhereCondition(WhereCondition whereParam){
		opWhereConditions.add(whereParam);
		return this;
	}


	public List<WhereCondition> getWhereConditions() {
		return whereConditions;
	}

	public void setWhereConditions(List<WhereCondition> whereConditions) {
		this.whereConditions = whereConditions;
	}

	public List<WhereCondition> getOpWhereConditions() {
		return opWhereConditions;
	}

	public void setOpWhereConditions(List<WhereCondition> opWhereConditions) {
		this.opWhereConditions = opWhereConditions;
	}
	
	

}
